//
//  LeftViewController.m
//  Streaming
//
//  Created by 韩一博 on 15/6/30.
//  Copyright (c) 2015年 liuxun. All rights reserved.
//

#import "LeftViewController.h"

@interface LeftViewController ()

@end

@implementation LeftViewController

- (void)dealloc
{
    [self.tableView release];
    
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self create];
    // Do any additional setup after loading the view.
}
- (void)create
{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height / 4, self.view.frame.size.width, self.view.frame.size.height / 2)];
    
    self.tableView.backgroundColor = [UIColor clearColor];
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    leftImageView.image = [UIImage imageNamed:@"3.jpg"];
    [self.view addSubview:leftImageView];
    
    [self.view addSubview:self.tableView];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;//取消cell之间的线
    [self.tableView release];
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellName = @"myCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
    }
    if (indexPath.row == 0 && indexPath.section == 0) {
        cell.textLabel.text = @"首页";
    }
    if (indexPath.row == 1 && indexPath.section == 0) {
        cell.textLabel.text = @"我的收藏";
    }
    if (indexPath.row == 2 && indexPath.section == 0) {
        cell.textLabel.text = @"设置";
    }
    
    cell.backgroundColor = [UIColor clearColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;//取消点击效果
    
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.row == 0) {
        
        MovieViewController *movieVC = [[MovieViewController alloc] init];
        UINavigationController *movieNav = [[UINavigationController alloc] initWithRootViewController:movieVC];
        UIImage *movieImage = [UIImage imageNamed:@"iconfont-dianying.png"];
        UIImage *movieselectedImage = [UIImage imageNamed:@"iconfont-dianying-2.png"];
        movieNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"电影" image:movieImage selectedImage:movieselectedImage];
        
        CemeraViewController *cemeraVC = [[CemeraViewController alloc] init];
        UINavigationController *cemeraNav = [[UINavigationController alloc] initWithRootViewController:cemeraVC];
        UIImage *cemeraImage = [UIImage imageNamed:@"iconfont-icon2.png"];
        UIImage *cemeraselectedImage = [UIImage imageNamed:@"iconfont-icon.png"];
        cemeraNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"排行榜" image:cemeraImage selectedImage:cemeraselectedImage];
        
        CommentViewController *newsVC = [[CommentViewController alloc] init];
        UINavigationController *newsNav = [[UINavigationController alloc] initWithRootViewController:newsVC];
        UIImage *newsImage = [UIImage imageNamed:@"iconfont-pinglun-3.png"];
        UIImage *newsselectedImage = [UIImage imageNamed:@"iconfont-pinglun-4.png"];
        newsNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"影评" image:newsImage selectedImage:newsselectedImage];
        
        RealViewController *shopVC = [[RealViewController alloc] init];
        UINavigationController *shopNav = [[UINavigationController alloc] initWithRootViewController:shopVC];
        UIImage *shopImage = [UIImage imageNamed:@"iconfont-redian.png"];
        UIImage *shopselectedImage = [UIImage imageNamed:@"iconfont-redian-2.png"];
        shopNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"热点" image:shopImage selectedImage:shopselectedImage];
        
        PrevueViewController *prevueVC = [[PrevueViewController alloc] init];
        UINavigationController *prevueNav = [[UINavigationController alloc] initWithRootViewController:prevueVC];
        UIImage *mainImage = [UIImage imageNamed:@"iconfont-huandengpian.png"];
        UIImage *mainselectedImage = [UIImage imageNamed:@"iconfont-huandengpian-2.png"];
        prevueNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"预告片" image:mainImage selectedImage:mainselectedImage];
        
        movieNav.navigationBar.barTintColor = [UIColor colorWithRed:31 / 255.0 green:115 / 255.0 blue:192 / 255.0 alpha:0.3f];
        cemeraNav.navigationBar.barTintColor = [UIColor colorWithRed:31 / 255.0 green:115 / 255.0 blue:192 / 255.0 alpha:0.5f];
        newsNav.navigationBar.barTintColor = [UIColor colorWithRed:31 / 255.0 green:115 / 255.0 blue:192 / 255.0 alpha:0.3f];
        shopNav.navigationBar.barTintColor = [UIColor colorWithRed:31 / 255.0 green:115 / 255.0 blue:192 / 255.0 alpha:0.3f];
        prevueNav.navigationBar.barTintColor = [UIColor colorWithRed:31 / 255.0 green:115 / 255.0 blue:192 / 255.0 alpha:0.3f];

        
        UITabBarController *tabBarC = [[UITabBarController alloc] init];
        tabBarC.viewControllers = [NSArray arrayWithObjects:movieNav, cemeraNav,newsNav, shopNav, prevueNav, nil];
        tabBarC.tabBar.translucent = NO;
        [self.sideMenuViewController setContentViewController:tabBarC animated:YES];
        [self.sideMenuViewController hideMenuViewController];//返回主界面
        
    }
    if (indexPath.row == 1) {
        FifthViewController *fifth = [[FifthViewController alloc] init];
        [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:fifth] animated:YES];
        [self.sideMenuViewController hideMenuViewController];//返回主界面
    }

    if (indexPath.row == 2) {
        FourthViewController *fourth = [[FourthViewController alloc]init];
        [self.sideMenuViewController setContentViewController:[[UINavigationController alloc] initWithRootViewController:fourth]animated:YES];
        [self.sideMenuViewController hideMenuViewController];//返回主界面
    }
    
    
}








- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
